﻿//Login.aspx.cs
////////////////////////////////////////
////////////////////////////////////////
//管理员登录页面
////////////////////////////////////////
////////////////////////////////////////
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Manager_Login : System.Web.UI.Page
{
    CommonClass ccObj = new CommonClass();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            this.labValid.Text = ccObj.RandomNum(4);//产生随机验证码
        }
    }
    protected void btnCancel_Click(object sender, EventArgs e)
    {
        ManagerID.Text = "";
        Managerpsw.Value = "";
    }
    protected void btnLogin_Click(object sender, EventArgs e)
    {
        //清空Session对象
        Session["Admin"] = null;
        if (this.ManagerID.Text.Trim() == "")
        {
            Response.Write(ccObj.MessageBoxPage("登录名不能为空！"));
        }
        else if (this.Managerpsw.Value.Trim() == "")
        {
            Response.Write(ccObj.MessageBoxPage("密码不能为空！"));
        }
        else if (this.txtValid.Text.Trim() == "")
        {
            Response.Write(ccObj.MessageBoxPage("验证码不能为空！"));
        }
        else
        {
            if (this.txtValid.Text.Trim() == this.labValid.Text.Trim())
            {
                //////////////////////////////////
                //////////////////////////////////
                //调用函数(输入用户名和密码验证)判断用户[this.ManagerID.Text.Tostring().Trim(),this.Managerpsw.Value.ToString().Trim()]是否存在,若存在，则：
                /* Admin admin = new Admin();
                 * SqlDataReader dr = admin.函数(参数1，参数2);
                 * if(dr.Read())
                 * {
                 *      admin = new Admin(dr["ManagerID"].ToString(),……);
                 * }
                 * Session["Admin"] = admin;
                 * */
                Session["Admin"] = "sky"; //实验
                Response.Redirect("ManagerDefault.aspx");
            }
            else
            {
                Response.Write(ccObj.MessageBoxPage("请正确输入验证码！"));
            }
        }
    }
}
